<?php

class Application_Model_WayItem extends Application_Model_DomainObject{
    
    protected $_id;
    
    protected $_wayId;//运单ID
    
    protected $_storeItemId; //货物ID
    
    protected $_status;//操作状态
    /**
     * 未拣货
     */
    const Status_Initial = 0;
    /**
     * 已拣货
     */
    const Status_Picking = 1;
    
    /**
     * 已丢失
     */
    const Status_Lose = 2;

    /**
     * 跟据运单ID返回
     * @param type $wayId
     * @return array
     */
    public static function getByWayId($wayId){
        return self::getDao()->queryAll(array('wayId'=>$wayId));
    }
    
    
    public function getStoreItem(){
        return Application_Model_StoreItem::load($this->_storeItemId);
    }
    
    public static function getWayIdStoreIdByStatus($wayId,$storeId)
    {
        return self::getDao()->queryOne(array("wayId"=>$wayId," and storeItemId = "=>$storeId));
    }
    
    public function getPickStatusName()
    {
        switch ($this->_status) {
            case self::Status_Initial:
                return "未拣货";
                break;
            case self::Status_Picking:
                return "已拣货";
                break;
            case self::Status_Lose:
                return "已丢失";
                break;
            default:
                return "未拣货";
                break;
        }
    }
    
    public function getStoreIdByItem()
    {
        return Application_Model_StoreItem::load($this->_storeItemId);
    }
}